<template>
    <a-card :bordered="false">
      <div class="table-operator">
          <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'bannerForm','新增')">新增</a-button>
      </div>
        <LTable
        ref="bannerList"
        size="middle"
        :rowKey="record=>record.keyId"
        :columns="columns"
        axiosUrl="/KhyBannerController/page"
        :showPagination="true"
        :showQueryForm="true"
        :initOrder="[{field:'createTime',val:'desc'}]">
      <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'bannerForm','详情')">详情</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId},'/KhyBannerController/del','bannerList')">
                <a>删除</a>
            </a-popconfirm>
      </span>
       <span slot="bannerImg" slot-scope="text">
          <img style="width:100px;heigth:100px" :src="defaultSettings.fileServer+'/'+text" />
      </span>
      
       
    </LTable>
      <bannerForm ref="bannerForm" @close="refresh('bannerList')" @ok="refresh('bannerList')"></bannerForm> 
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'
import bannerForm from './bannerForm'
import {filterDictText} from '@/utils/util'

export default {
    name:'bannerList',
    components:{
       LTable,
       bannerForm
    },
    mixins:[SysMixin],
    data(){
        return{
            initDictCodes:defaultSettings.数据字典.是否,
            defaultSettings,
            
            columns:[
                {
                  
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
          
                {
                    title: '图片',
                    dataIndex: 'bannerImg',
                    scopedSlots: { customRender: 'bannerImg' }
                },
                {
                    title: '是否可用',
                    dataIndex: 'isUse',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.是否,text)
                        }
                    }
                    
                },
                 {
                    title: '排序',
                    dataIndex: 'bannerOrder'
                },  
                {
                    title: '创建时间',
                    dataIndex: 'createTime'
                },  
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '150px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
        
        }
    },
    created(){
       
    },
    methods:{
      
    }
}
</script>